package
{
	import flash.display.Graphics;

	public class GestureLibrary
	{
		private var learner:InstanceLearner;
		public function GestureLibrary()
		{
			learner = new InstanceLearner();
		}
		
		public function addGesture(label:String,posList:Vector.<Number>):void{
			var instance:Instance = Instance.createInstance(posList,label);
			learner.addInstance(instance);
		}
		
		public function removeGesture(label:String):void{
			learner.removeInstance(label);
		}
		
		public function clearGestures():void{
			learner.clearInstance();
		}
		
		public function match(posList:Vector.<Number>):Instance{
			var instance:Instance = Instance.createInstance(posList);
			instance = learner.classify(instance.vector);
			return instance;
//			if(instance.score>3){
//				return instance;
//			}else{
//				return null;
//			}
		}
		
		public function debug(posList:Vector.<Number>,g:Graphics):void{
			var instance:Instance = Instance.createInstance(posList);
			var len:int = instance.vector.length;
			g.moveTo(instance.vector[0]*1,instance.vector[1]*1);
			trace(len);
			for(var i:int = 2 ; i < len ; i +=2){
				g.lineTo(instance.vector[i]*1,instance.vector[1+i]*1);
			}
			for(i = 0 ; i < len ; i +=2){
				g.drawCircle(instance.vector[i]*1,instance.vector[1+i]*1,2);
			}
		}
	}
}